﻿Option Explicit On

Imports System.Windows.Forms
Imports System.Drawing
Imports System.Drawing.Graphics
Imports BPEditor.mdlGlobal

Public Class shpActivator
    Private m_Ancestor As Object
    Private m_Index As Long
    Private m_Link As Object
    Private m_Left As Double, m_Top As Double
    Private m_Focus As Boolean

    'Public Event Move(ByVal X As Double, ByVal Y As Double)

    Public Property Index() As Long
        Get
            Return m_Index
        End Get
        Set(ByVal value As Long)
            m_Index = value
        End Set
    End Property

    Public Property Ancestor() As Object
        Get
            Return m_Ancestor
        End Get
        Set(ByVal value As Object)
            m_Ancestor = value
        End Set
    End Property

    Public Property Link() As Object
        Get
            Return m_Link
        End Get
        Set(ByVal value As Object)
            m_Link = value
        End Set
    End Property

    Public ReadOnly Property nLeft() As Double
        Get
            Return m_Left
        End Get
    End Property

    Public ReadOnly Property nTop() As Double
        Get
            Return m_Top
        End Get
    End Property

    Private Sub shpActivator_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        Width = c_WidthPort
        Height = c_HeightPort
    End Sub

    Private Sub shpActivator_Paint(ByVal sender As System.Object, ByVal e As PaintEventArgs) Handles Me.Paint
        Dim shpPen As New Pen(ColorSelectPort, c_BorderPort), shpBrush As New SolidBrush(ColorActivator)
        e.Graphics.FillEllipse(shpBrush, 0, 0, c_WidthPort - c_BorderPort, c_HeightPort - c_BorderPort)
        If m_Focus Then
            e.Graphics.DrawEllipse(shpPen, 0, 0, c_WidthPort - c_BorderPort, c_HeightPort - c_BorderPort)
        End If
        SetStyle(ControlStyles.SupportsTransparentBackColor, True)
    End Sub

    Private Sub UserControl_GotFocus(ByVal sender As Object, ByVal e As EventArgs) Handles Me.GotFocus
        m_Focus = True
        'shpActivator_Paint(Me, New PaintEventArgs())
    End Sub

    Private Sub UserControl_LostFocus(ByVal sender As Object, ByVal e As EventArgs) Handles Me.LostFocus
        m_Focus = False
        'shpActivator_Paint(Me, New PaintEventArgs())
    End Sub

    'Public Sub Position(ByVal lef As Double, ByVal top As Double)
    '    If lef > 0 Then
    '        m_Left = lef
    '    Else
    '        m_Left = 0
    '    End If
    '    If top > 0 Then
    '        m_Top = top
    '    Else
    '        m_Top = 0
    '    End If
    '    MoveTo()
    'End Sub

    'Public Sub MoveTo()
    '    RaiseEvent Move(m_Left, m_Top)
    'End Sub

    'Private Sub shpActivator_MouseDown(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles Me.MouseDown
    '    Dim con As shpConnector
    '    m_ActiveObject = Me
    '    Select Case e.Button
    '        Case Windows.Forms.MouseButtons.Middle
    '        Case Windows.Forms.MouseButtons.Right
    '        Case Windows.Forms.MouseButtons.Left
    '            If m_ActivePort Is Nothing Then
    '                m_ActivePort = Me
    '                Focus(True)
    '            ElseIf m_ActivePort Is Me Then
    '                m_ActivePort = Nothing
    '                Focus(False)
    '            Else
    '                'con = m_Editor.AddConnector(m_ActivePort, Me)
    '                m_ActivePort = Nothing
    '                'con.Port1.Focus False
    '                Focus(False)
    '            End If
    '    End Select
    'End Sub

    'Private Sub shpActivator_MouseUp(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles Me.MouseUp
    '    m_ActiveObject = Me
    '    Select Case e.Button
    '        Case Windows.Forms.MouseButtons.Middle
    '        Case Windows.Forms.MouseButtons.Right
    '            'm_Editor.InvokeMenu inActivatorMenu
    '        Case Windows.Forms.MouseButtons.Left
    '    End Select
    'End Sub

    'Private Sub shpActivator_Move(ByVal sender As System.Object, ByVal e As MouseEventArgs) Handles Me.MouseMove
    '    'MousePointer = vbArrow
    'End Sub

    'Private Sub UserControl_Resize(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Resize
    '    shpActivator_Paint(Me, New EventArgs())
    'End Sub
End Class
